import {GetUserInfoAPI} from "@/request/api"

export default{
    namespaced:true,
    state:{
        cartTotal:0,
        userInfo:{
            headImg:require("../../assets/img/userImg.f8bbec5e.png"),
            nickName:"游客11",
            coin:"---"
        }
    },
    mutations:{
        changeUserInfo(state,payload){
            state.cartTotal = payload.cartTotal;
            state.userInfo = payload.userInfo;
        },
        initUserInfo(state){
            state.cartTotal = 0;
            state.userInfo = {
                headImg:require("../../assets/img/userImg.f8bbec5e.png"),
                nickName:"游客11",
                coin:"---"
            }
        }
    },
    actions:{
        async asyncChangeUserInfo({commit}){
            let res = await GetUserInfoAPI()
            // console.log("Vuex中-请求到的用户信息为：",res);
            commit("changeUserInfo", res.data)
        }
    }

    
}